package org.example.Controller;

import jakarta.annotation.Resource;
import org.example.common.Result;
import org.example.pojo.Goods;
import org.example.pojo.Query;
import org.example.service.GoodsService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("Goods")
public class GoodController {
    @Resource
    private GoodsService goodsService;
    @PostMapping("/list")
    public Result list(@RequestBody Query query){
        Result result=goodsService.getlist(query);
        return result;

    }
    @PostMapping("/add")
    public Result add(@RequestBody Goods goods){
        Result result=goodsService.add(goods);
        return result;

    }
    @PostMapping("/update")
    public Result update(@RequestBody Goods goods){
        Result result=goodsService.updateGood(goods);
        return result;
    }
    @PostMapping("/delete")
    public Result delete(Integer id){
        Result result=goodsService.deletegoods(id);
        return result;
    }
    @PostMapping("/selectByIDandCID")
    public Result getselectid (Integer id,Integer busId){
        Result result=goodsService.selectbyid(id,busId);

        return result;
    }

}
